<template>
	<div class="export-dialog-view" v-loading="pageLoading">
		<div class="export-dialog">
			<div class="left-lay">
				<div class="split-title">{{ title }}</div>

				<div class="left-line">
					<div class="split-title p0">
						{{ $t("message.ReportFormTable.E_A.lab1") }}
					</div>
				</div>
				<div class="left-line">
					<div class="line-title">
						{{ $t("message.bhView.leftComponents.device") }}
					</div>
					<div class="line-value">{{ $store.state.plantName }}</div>
				</div>

				<div class="left-line">
					<div class="line-title">
						{{ $t("message.bhView.leftComponents.object") }}
					</div>
					<div class="line-value">
						{{
							$store.state.macType == 1
								? $t("message.bhView.leftComponents.machine")
								: $t("message.bhView.leftComponents.piping")
						}}
					</div>
				</div>

				<div class="left-line">
					<div class="line-title">
						{{ $t("message.reportFrom.exportDialog.title_c") }}
					</div>
					<div class="line-value">{{ fileTypeStr }}</div>
				</div>



				<div class="left-draw" id="left-draw"></div>
			</div>

			<div class="tip-lay"></div>

			<div class="right-lay">
				<div class="split-title text-right">
					<i class="el-icon-close" @click="CloseExprotDiloag"></i>
				</div>
				<div class="split-title">
					{{ $t("message.reportFrom.exportDialog.title_l") }}
				</div>

				<div class="right-block-container">
					<div class="right-line">
						<div class="line-title">
							測定年度指定
						</div>
					</div>
					<div class="right-line">
						<el-date-picker v-model="FromYear" type="month" :format="format" :value-format="format"
							placeholder=" " class="ipt picker">
						</el-date-picker>
						<span>~</span>
						<el-date-picker v-model="ToYear" type="month" :format="format" :value-format="format"
							placeholder=" " class="ipt picker orange">
						</el-date-picker>
					</div>
				</div>

				<div class="right-block-container">
					<div class="right-line">
						<div class="line-title">
							{{ $t("message.reportFrom.exportDialog.title_b") }}
						</div>
					</div>
					<div class="right-line">
						<el-radio-group v-model="formCorrRateRule">
							<el-radio :label="4">{{
								$t("message.reportFrom.exportDialog.radio_1d")
							}}</el-radio>
							<el-radio :label="1">{{
								$t("message.reportFrom.exportDialog.radio_1a")
							}}</el-radio>
							<el-radio :label="2">{{
								$t("message.reportFrom.exportDialog.radio_1b")
							}}</el-radio>
							<el-radio :label="3">{{
								$t("message.reportFrom.exportDialog.radio_1c")
							}}</el-radio>
						</el-radio-group>
					</div>
				</div>


				<div class="right-block-container">
					<div class="right-line">
						<div class="line-title">
							{{ $t("message.reportFrom.exportDialog.title_d") }}
						</div>
					</div>
					<div class="right-line">
						<el-checkbox-group v-model="formDeterName" :min="1">
							<el-checkbox checked :label="0">{{
								$t("message.reportFrom.exportDialog.check_3a")
							}}</el-checkbox>
							<el-checkbox :label="1">{{
								$t("message.reportFrom.exportDialog.check_3b")
							}}</el-checkbox>
						</el-checkbox-group>
					</div>
				</div>

				<div class="right-block-container">
					<div class="right-line">
						<div class="line-title">
							印刷対象
						</div>
					</div>
					<div class="right-line">
						<el-radio-group v-model="printobj">
							<el-radio :label="1">指定時期測定箇所のみ</el-radio>
							<el-radio :label="2">全測定箇所</el-radio>
						</el-radio-group>
					</div>
				</div>

				<div class="right-block-container">
					<div class="right-line">
						<div class="line-title">
							定点区分
						</div>
					</div>
					<div class="right-line"
						style="border: 1px solid #D9D9D9FF;padding:10px 0 30px 10px;margin: 12px 0 0 10px;border-top: 1px solid #D9D9D9FF;">
						<el-checkbox-group v-model="onPointDifferentiation">
							<el-checkbox :label="index + 1" v-for="(item, index) in M.pointDifferentiation" :key="index"
								style="width: 80px;">
								{{ item }}
							</el-checkbox>
						</el-checkbox-group>
					</div>
				</div>

				<div class="right-line bottom-border" style="border-top: 1px solid #f0f0f0;margin-top: 20px;;">
					<div class="line-title" style="width: 30%">
						{{ $t("message.reportFrom.exportDialog.title_j") }}
					</div>
					<div class="line-content">
						<!-- <el-select v-model="operDate" class="select-ipt orange" style="margin: 0 8px 0 16px"
							placeholder=" ">
							<el-option v-for="item in LifeAssBaseDate" :key="item" :label="item" :value="item">
							</el-option>
						</el-select> -->
						<el-select v-model="operDate" class="select-ipt orange" style="margin: 0 8px 0 16px"
							placeholder=" ">
							<el-option v-for="item in LifeAssBaseDate" :key="item.value" :label="item.label"
								:value="item.value">
							</el-option>
						</el-select>
					</div>
				</div>
				<div class="LineEcharts_warp">
					<div>{{ showName }}</div>
					<div id="LineEcharts"></div>
				</div>
			</div>
			<footer class="footer-view">
				<div class="">
					<div class="line-title" style="width: 100%">
						{{ $t("message.reportFrom.exportDialog.tip") }}
					</div>
				</div>
				<div>
					<el-button @click="CloseExprotDiloag">Cancel</el-button>
					<el-button type="primary" @click="onExportClick">OK</el-button>
				</div>
			</footer>
		</div>
	</div>
</template>

<script>
import {
	ExPDFTicketThicknessMapReport,
	VerifyDate,
	GetTicketThicknessMapInput,
	getLineChartData,
	GetTicketThicknessMapPointInput,
	getThckLineChatDate,
	GetThickDeterResLifeAssBaseDate,
	// DEL
	getLifeAssBaseDate,
	getWindcraftJudgColor,

	ExThckDeterResReportVerify,
	ExThckDeterResReport,
	CollectFiles
} from "@/api/api";
import { getLocalStorage } from "@/utils/storage";
import timeFormat from "@/utils/timeFormat";

var algebra = require("algebra.js");
import $ from 'jquery'

export default {
	props: ["title", "fileTypeStr", "selectMacData", "fileRadio"],
	name: "E_D_Export",
	data() {
		return {
			Data: {},
			M: {},
			onPointDifferentiation: [],
			pageLoading: false,
			FromYear: '',
			ToYear: '',
			formExDate: "",
			formCorrRateRule: 4,
			formDeterName: [],
			operDate: "",
			format: timeFormat(),
			PrintType: 1,
			Draw: false,
			showName: '',
			isSHowEcharts: false,
			printobj: 1,
			LifeAssBaseDate: [],

			continueFlg: 1,	// 不知名报错卡住的时候来解决
		};
	},
	components: {},
	watch: {},
	methods: {
		getLifeAssBaseDateApi() {
			GetThickDeterResLifeAssBaseDate({
				PltCode: this.$store.state.pltCode,
			}).then((res) => {
				if (res.data.code != 0) {
					return;
				}
				res.data.data.forEach((dateItem) => {
					this.LifeAssBaseDate.push({
						label: dateItem,
						value: dateItem,
					});
				});
				this.operDate = this.LifeAssBaseDate[6].value;
			});
		},

		async initFn() {
			this.getLifeAssBaseDateApi();
			let D = {};
			let R = await GetTicketThicknessMapInput(D);

			this.M = R.data.data;
			// this.operDate = this.M.year[6];
			this.ToYear = this.M.year[6];

		},

		async VerifyDateFn() {
			let D = {
				fromDate: this.FromYear,
				toDate: this.ToYear,
			};
			let R = await VerifyDate(D);
			console.log(R);
			if (!R) {
				return 'stop'
			}
		},

		async getStr() {
			let MacNumb = [];
			for (let i = 0; i < this.selectMacData.length; i++) {
				MacNumb.push(this.selectMacData[i].macName);
			}
			let D = {
				PltCode: `${this.selectMacData[0].pltCode}`,
				MacType: this.selectMacData[0].macType,
				MacNumb,	//是	List<string>	机器名称，数组，选中多少传多少，如100-E001
				// 如果一位则为0时，选中
				PointOn: this.formDeterName.length == 1 ? this.formDeterName[0] == 0 ? 2 : 1 : 2,
				PointName: this.formDeterName.length == 1 ? this.formDeterName[0] == 1 ? 2 : 1 : 2,

				CorrosionRate: this.formCorrRateRule,
				fromYear: this.FromYear,
				toYear: this.ToYear,
				printobj: this.printobj,
				OnPointDifferentiation: this.onPointDifferentiation,
				Year: this.operDate,
			};
			try {
				let R = await GetTicketThicknessMapPointInput(D);
				console.log(R);
				if (!R) {
					return 'stop'
				}
				return R.data.data;
			} catch (error) {
			}
		},
		// 注意此方法 的使用，·1，阻止下一次循环。2，当echarts没有绘制完成时，阻止，延迟一秒是为了，将折线绘制完成再转图片。
		wait() {
			return new Promise((resolve, reject) => {
				if (this.Draw) {
					this.continueFlg++;
					resolve();
				} else {
					const intervalId = setInterval(() => {
						if (this.Draw) {
							this.continueFlg++;
							clearInterval(intervalId);
							resolve();
						}
					}, 100);
				}
			});
		},
		async onExportClick() {
			// let dmgCode;
			// if (this.$store.state.macType == 1) {
			// 	dmgCode = this.selectMacData.filter(aa => aa.macName == item.split('&')[0])[0].macCode;
			// }
			// console.log(dmgCode,this.selectMacData);
			// return
			// 验证日期
			let M1 = await this.VerifyDateFn();
			if (M1 == 'stop') {
				return
			}
			// 验证XX
			let M2 = await this.getStr();
			if (M2 == 'stop') {
				return
			}
			this.isSHowEcharts = true;
			this.pageLoading = true;


			let SvgHtmls = {};
			for (let i = 0; i < M2.length; i++) {
				this.Draw = false;
				let item = M2[i];



				this.showName = item;
				// if (this.$store.state.macType == 1) {
				// 	dmgCode = this.selectMacData.filter(aa => aa.macName == item.split('&')[0])[0].macCode;
				// }
				// if (this.$store.state.macType == 2) {
				// dmgCode = this.selectMacData.filter(aa => aa.macName == item.macNum)[0].macCode;

				let DA = await this.getThckLineChatDateApi(
					{
						Account: getLocalStorage("userName"),
						dmgCode: Number(item.dmg_code),
						PosNo: Number(item.psoNo),
						ClsType: Number(item.clsType),
						IsReportReq: true
					}
				);
				console.log(DA);
				this.continueFlg = 1;
				// }
				if (Object.keys(DA).length == 0)
					continue;

				try {
					SvgHtmls[item.imageKey] = await this.getLineChartDataApi(item.macNum, item.imageKey.split('&')[2].toString(), Number(item.posOrdr), Number(item.dmg_code), DA.fromDate[0], DA.toDate[0]) || '';
					console.log('SvgHtmls[item.imageKey]', item.imageKey, SvgHtmls[item.imageKey]);
				} catch (error) {

				}

				await this.wait();

			}

			console.log(SvgHtmls);

			let MacNumb = [];
			for (let i = 0; i < this.selectMacData.length; i++) {
				MacNumb.push(this.selectMacData[i].macName);
				// let Url = await this.getLineChartDataApi();
			}
			let D = {
				PltCode: `${this.selectMacData[0].pltCode}`,
				MacType: this.selectMacData[0].macType,
				MacNumb,	//是	List<string>	机器名称，数组，选中多少传多少，如100-E001
				// 如果一位则为0时，选中
				PointOn: this.formDeterName.length == 1 ? this.formDeterName[0] == 0 ? 2 : 1 : 2,
				PointName: this.formDeterName.length == 1 ? this.formDeterName[0] == 1 ? 2 : 1 : 2,
				printobj: this.printobj,
				CorrosionRate: this.formCorrRateRule,
				FromYear: this.FromYear,
				ToYear: this.ToYear,

				OnPointDifferentiation: this.onPointDifferentiation,
				SvgHtmls,
				Year: this.operDate,
			};
			try {
				let R = await ExPDFTicketThicknessMapReport(D);
				this.pageLoading = false;
				if (R.data.code != 0) {
					console.log("s5fd1");
					this.$alert(R.data.msg, '', {
						confirmButtonText: 'OK',
						type: 'warning',
						callback: action => {
						}
					})
					return
				}
				console.log(R);
				window.open(R.data.data);
				this.pageLoading = false;
				this.isSHowEcharts = false;
				this.$emit("CloseExprotDiloag");

			} catch (error) {
				this.pageLoading = false;
				this.isSHowEcharts = false;
				this.$emit("CloseExprotDiloag");

			}
		},
		// 获取折线图日期
		async getThckLineChatDateApi(D) {

			let R = await getThckLineChatDate(D);
			return R.data.data
		},



		CloseExprotDiloag() {
			this.$emit("CloseExprotDiloag");
		},


		// 折线图
		//获取折线图数据   
		async getLineChartDataApi(macNum, msrPnt, posOrdr, dmgCode, ispDateBegin, ispDateEnd) {
			console.log(111);
			// setTimeout(() => {
			// 	if (this.continueFlg == 1) {
			// 		this.Draw = true;
			// 		return ''
			// 	}
			// }, 7000);
			// let dataJson = {
			// 	"pltName": "",
			// 	"macNum": "100-V606A",
			// 	"posOrdr": 2,
			// 	"msrPnt": "1",
			// 	"ispDateBegin": "1994-07-01",
			// 	"ispDateEnd": "2008-07-01",
			// 	"dmgCode": 18986,
			// 	"lifeAssBaseDate": "2023-06",
			// 	"pltCode": 9,
			// 	"UserId": "16d3abfd-fe49-4028-b12e-fda69c46c176",
			// 	"Account": "admin"
			// };

			let dataJson = {
				pltName: "",
				macNum,
				posOrdr,
				msrPnt: msrPnt == '-' ? '' : msrPnt,
				ispDateBegin,
				ispDateEnd,
				dmgCode,
				lifeAssBaseDate: this.operDate,
				pltCode: this.selectMacData[0].pltCode,
				UserId: getLocalStorage("userID"),
				Account: getLocalStorage("userName"),
				IsReportReq: true
			};

			let res = await getLineChartData(dataJson);

			try {

				if (res.data.code == -400) {
					this.$message({
						message:
							this.$t('message.public.tip3'),
						type: "warning",
					});
					document.getElementById("LineEcharts").innerHTML = "";
					this.Draw = true;
					return '';
				}
				if (res.data.code != 0) {
					//没有数据清空图表
					document.getElementById("LineEcharts").innerHTML = "";
					this.Draw = true;
					return '';
				}
				this.Data = res.data.data;
				let data = res.data.data;
				//判断格式，改成年月日类型的
				let dType = false;
				let tempDate = [];
				data.date.forEach(i => {
					if (i.split('-')[2].length == 4) {
						dType = true;
						i = `${i.substr(6, 9)}-${i.substr(0, 5)}`
						tempDate.push(i)
					}
				})
				if (dType) data.date = tempDate;

				if (
					data.date.length == 0 ||
					data.datePeriodBegin.length == 0 ||
					data.datePeriodEnd.length == 0
				) {
					return;
				}
				console.log(data, '获取折线图数据');
				return this.IinearEquationInTwoUnknowns(data);
			} catch (error) {
				document.getElementById("LineEcharts").innerHTML = "";
			}
		},
		//折线图生成
		async drawLine(
			date,
			managerValue,
			wallThck,
			lineNameList,
			ORG_THCK,
			verticalAxisMinValue,
			lineChartST,
			lineLongChartST,
			verticalAxisMaxValue,
			leastSquare,
			realValue,
			positionName
		) {
			console.log(444);

			let myChart = this.$echarts.init(
				document.getElementById("LineEcharts")
			);
			let _this = this;
			let option = {
				backgroundColor: "rgb(255,250,240)",
				tooltip: {
					trigger: "axis",
					formatter: function (params) {
						// console.log(params, "params-----");
						let list = [
							`<span style="width:200px; display:inline-block;margin-left:20px">${_this.$t(
								"message.chart.label_1"
							)}&nbsp&nbsp${params[0].value[0]}</span><br>
              <span style="width:200px; display:inline-block;margin-left:20px">${_this.$t(
								"message.chart.label_2"
							)}&nbsp&nbsp${positionName}</span>
            `,
						];
						let listItem = "";
						params.forEach((element) => {
							if (typeof element.value == "undefined") {
								element.value = "";
							}
							if (
								element.seriesName != "长期" &&
								element.seriesName != "短期" &&
								element.seriesName != "最小二乘法"
							) {
								list.push(
									`<i style="display: inline-block;width: 10px;height: 10px;background:${element.color
									};margin-right: 5px;border-radius: 50%;}"></i>
                <span style="width:200px; display:inline-block;">${element.seriesName
									}&nbsp&nbsp${element.value[1]
										? element.value[1]
										: element.value[1] === null
											? ""
											: element.value[0]
									}</span> 
                `
								);
							}
						});
						listItem = list.join("<br>");
						return '<div class="showBox">' + listItem + "</div>";
					},
				},
				color: [
					// "rgb(156, 44, 154)", //紫
					// "rgb(206, 200, 142)", //黄
					"rgb(206, 200, 142)", //黄
					"rgb(156, 44, 154)", //紫
					"rgb(30, 30, 255)", //蓝
					"rgb( 255, 31, 30)", //红
					"rgb(0,128,0)", // 绿
					"rgb( 0,0,0)", //黑
				],
				legend: {
					data: lineNameList,
					top: 10,
				},
				grid: {
					top: "10%",
					left: "3%",
					right: "4%",
					bottom: "5%",
					containLabel: true,
				},
				xAxis: {
					type: "time",
					boundaryGap: false,
					data: date,
					axisLabel: {
						rotate: 0, // 旋转角度
						interval: this.interval, //设置X轴数据间隔几个显示一个，为0表示都显示
					},
					splitLine: {
						show: false,
					},
				},
				yAxis: {
					type: "value",
					max: verticalAxisMaxValue,
					// min: 2, //纵坐标最小值
					min: verticalAxisMinValue,
					splitLine: {
						show: false,
					},
				},
				series: [
					// {
					// 	name: wallThck.name,
					// 	type: "line",
					// 	data: wallThck.data,
					// 	smooth: false,
					// 	symbol: "none",
					// 	itemStyle: {
					// 		normal: {
					// 			lineStyle: {
					// 				color: "rgb(156, 44, 154)",
					// 				//  type:'dotted'
					// 			},
					// 		},
					// 	},
					// },
					{
						name: wallThck.name,
						type: "line",
						data: wallThck.data,
						symbol: "none",
						itemStyle: {
							normal: {
								lineStyle: {
									color: "rgb(206, 200, 142)",
								}
							}
						},
						markPoint: {
							data: [
								{
									coord: [date[date.length - 1], wallThck.data[wallThck.data.length - 1].value[1]],
									symbolSize: 1,

									label: {
										formatter: [
											`{a|${this.Data.initVal}}`,
										].join('\n'),
										backgroundColor: 'rgb(173,216,230)',
										borderColor: '#333',
										borderWidth: 2,
										padding: 5,
										color: '#000',

										lineHeight: 30,
										rich: {
											a: {
												color: '#000',
												lineHeight: 10,
											},
										}
									}
								}
							]
						},
					},

					// {
					// 	name: managerValue.name,
					// 	type: "line",
					// 	data: managerValue.data,
					// 	symbol: "none",
					// 	itemStyle: {
					// 		normal: {
					// 			lineStyle: {
					// 				color: "rgb(206, 200, 142)",
					// 				//  type:'dotted'
					// 			},
					// 		},
					// 	},
					// },

					{
						name: managerValue.name,
						type: "line",
						data: managerValue.data,
						smooth: false,
						symbol: "none",
						itemStyle: {
							normal: {
								lineStyle: {
									color: "rgb(156, 44, 154)",
								},
							},
						},
						markPoint: {
							data: [
								{
									coord: [date[date.length - 1], managerValue.data[managerValue.data.length - 1].value[1]],
									symbolSize: 1,

									label: {
										formatter: [
											`{a|${this.Data.manVal}}`,
										].join('\n'),
										backgroundColor: 'rgb(173,216,230)',
										borderColor: '#333',
										borderWidth: 2,
										padding: 5,
										color: '#000',

										lineHeight: 30,
										rich: {
											a: {
												color: '#000',
												lineHeight: 10,
											},
										}
									}
								}
							]
						},
					},

					{
						name: lineChartST.name,
						type: "line",
						data: lineChartST.lineChartSTData,
						symbol: "none",
						smooth: false,
						itemStyle: {
							normal: {
								lineStyle: {
									color: "rgb(30, 30, 255)",
									type: "dotted",
								},
							},
						},
					},
					{
						name: lineLongChartST.name,
						type: "line",
						data: lineLongChartST.lineChartSTData,
						symbol: "none",
						smooth: false,
						itemStyle: {
							normal: {
								lineStyle: {
									color: "rgb( 255, 31, 30)",
									type: "dotted",
								},
							},
						},
					},
					{
						name: leastSquare.name,
						type: "line",
						data: leastSquare.data,
						connectNulls: true,
						symbol: "none",
						itemStyle: {
							normal: {
								lineStyle: {
									color: "rgb(0,128,0)",
									type: "dotted",
								},
							},
						},
					},
					//
					{
						name: realValue.name,
						type: "line",
						data: realValue.data,
						connectNulls: true,
						itemStyle: {
							normal: {
								lineStyle: {
									color: "rgb( 0,0,0)",
								},
							},
						},
					},
				],
			};
			this.$store.state.test = option;
			console.log(this.$store.state.test)
			myChart.setOption(option);
			$("#LineEcharts").removeAttr("_echarts_instance_");

			var base64Img = '';
			// var baseCanvas = document.getElementById("LineEcharts").getElementsByTagName("canvas")[0];
			const intervalId = setInterval(() => {
				if (myChart.getOption().animation) {
					clearInterval(intervalId);
					setTimeout(() => {
						base64Img = myChart.getDataURL();
						this.Draw = true;
					}, 2000);
				}
			}, 100);
			await this.wait();
			return base64Img;

		},
		//短期数据处理 二元一次方程
		IinearEquationInTwoUnknowns(data) {
			console.log(222);
			if (
				!data.lineChartST.lineChartSTData ||
				data.lineChartST.lineChartSTData.length == 0
			) {
				document.getElementById("LineEcharts").innerHTML = "";
				return;
			}


			// 短期数据处理
			let algebraData = data.lineChartST.lineChartSTData;

			var Equation = algebra.Equation;
			let Regtest = new RegExp(/-/g);
			let x1 =
				new Date(algebraData[0].stUpdateTime).getTime() / 100000000000;
			let x2 =
				new Date(algebraData[1].stUpdateTime).getTime() / 100000000000;

			// let x1 = algebraData[0].stUpdateTime.replace(Regtest, "").slice(0, 6);
			// let x2 = algebraData[1].stUpdateTime.replace(Regtest, "").slice(0, 6);
			let numberData1 = algebra.parse(
				`${algebraData[0].stValue} = k ${x1} + b`
			);
			let numberData2 = algebra.parse(
				`${algebraData[1].stValue} = k ${x2} + b`
			);
			var answer1 = numberData1.solveFor("k");
			var answer2 = numberData2.solveFor("k");
			//解出b值 
			var eq = new Equation(answer1, answer2);
			// console.log("b表达式：" + eq.toString());
			var answerB = 1;
			try {
				answerB = eq.solveFor("b");
			} catch (error) {

			}
			console.log(333);
			// console.log("解出b的值为：" + answerB.toString());
			try {
				eq = numberData1.eval({
					b: answerB,
				});
			} catch (error) {

			}

			// console.log("k表达式：" + eq.toString());
			var answerK = 1;
			try {
				answerK = eq.solveFor("k");
			} catch (error) {

			}
			console.log('answerK', answerK);

			// console.log("解出k的值为：" + answerK.toString());
			let lineChartST = {
				name: data.lineChartST.name,
				lineChartSTData: this.calculation(data.date, answerK, answerB),
			};

			// 长期数据处理 ------------------------------------------------
			// let algebralongData
			let algerbraLongData = data.lineChartSTLong.listLineChartSTLong;
			console.log(444);
			let x3 =
				new Date(algerbraLongData[0].stUpdateTime).getTime() /
				100000000000;
			let x4 =
				new Date(algerbraLongData[1].stUpdateTime).getTime() /
				100000000000;
			let numberData3 = algebra.parse(
				`${algerbraLongData[0].stValue} = j ${x3} + c`
			);
			let numberData4 = algebra.parse(
				`${algerbraLongData[1].stValue} = j ${x4} + c`
			);
			var answer3 = numberData3.solveFor("j");
			var answer4 = numberData4.solveFor("j");

			var eqLong = new Equation(answer3, answer4);
			// console.log("c表达式：" + eqLong.toString());
			var answerC = eqLong.solveFor("c");
			// console.log("解出c的值为：" + answerC.toString());
			eqLong = numberData3.eval({
				c: answerC,
			});
			// console.log("j表达式：" + eqLong.toString());
			var answerJ = 0;
			try {
				answerJ = eqLong.solveFor("j");
			} catch (error) {
				// console.log(error);
			}
			// console.log("解出j的值为：" + answerJ.toString());

			let lineLongChartST = {
				name: data.lineChartSTLong.name,
				lineChartSTData: this.calculationLong(
					data.date,
					answerJ,
					answerC
				),
			};

			// ----最小二乘法处理
			let leastSquareData = [];
			for (let i = 0; i < data.leastSquare.data.length; i++) {
				let arr = [];
				arr.push(data.date[i], data.leastSquare.data[i]);
				leastSquareData.push({ value: arr });
			}
			let leastSquareJson = {
				name: data.leastSquare.name,
				data: leastSquareData,
			};

			// ----测定值处理
			let realValueData = [];
			for (let i = 0; i < data.realValue.data.length; i++) {
				let arr = [];
				arr.push(data.date[i], data.realValue.data[i]);
				realValueData.push({ value: arr });
			}
			let realValueJson = {
				name: data.realValue.name,
				data: realValueData,
			};
			// ----管理值处理
			let managerValueData = [];
			for (let i = 0; i < data.managerValue.data.length; i++) {
				let arr = [];
				arr.push(data.date[i], data.managerValue.data[i]);
				managerValueData.push({ value: arr });
			}
			let managerValueJson = {
				name: data.managerValue.name,
				data: managerValueData,
			};

			// ---- 元肉厚

			let wallThckData = [];
			for (let i = 0; i < data.wallThck.data.length; i++) {
				let arr = [];
				arr.push(data.date[i], data.wallThck.data[i]);
				wallThckData.push({ value: arr });
			}
			let wallThckJson = {
				name: data.wallThck.name,
				data: wallThckData,
			};
			console.log(lineChartST, "lineChartST");
			// console.log(data.date,
			//   managerValueJson,
			//   wallThckJson,
			//   // 图例名称
			//   data.lineNameList,
			//   this.detailBhlTabel.ORG_THCK,
			//   data.verticalAxisMinValue,
			//   lineChartST,
			//   lineLongChartST,
			//   data.verticalAxisMaxValue,
			//   leastSquareJson,
			//   realValueJson,
			//   data.positionName, "------");
			console.log(333);
			return this.drawLine(
				// 时间
				data.date,
				managerValueJson,
				wallThckJson,
				// 图例名称
				data.lineNameList,
				1,
				data.verticalAxisMinValue,
				lineChartST,
				lineLongChartST,
				data.verticalAxisMaxValue,
				leastSquareJson,
				realValueJson,
				data.positionName
			);
		},
		calculationLong(xData, k, b) {
			let yData = [];
			let newXData = [];
			let Regtest = new RegExp(/-/g);
			let kVaule = k.numer / k.denom;
			let bVaule = b.numer / b.denom;
			xData.forEach((Item, index) => {
				newXData.push(new Date(Item).getTime() / 100000000000);
			});
			// newXData.forEach((Item) => {
			//   let num = kVaule * Item + bVaule;
			//   yData.push(Math.floor(num * 100) / 100);
			// });
			let x0 = kVaule * newXData[0] + bVaule;
			let xLast = kVaule * newXData.pop() + bVaule;
			yData.push([xData[0], Math.floor(x0 * 100) / 100]);
			yData.push([
				xData[xData.length - 1],
				Math.floor(xLast * 100) / 100,
			]);
			// let lineData = [];
			// for (let i = 0; i < xData.length; i++) {
			//   let arr = [];
			//   lineData.push(arr[(xData[i], yData[i])]);
			// }
			return yData;
		},

		calculation(xData, k, b) {
			let yData = [];
			let newXData = [];
			let Regtest = new RegExp(/-/g);
			let kVaule = k.numer / k.denom;
			let bVaule = b.numer / b.denom;
			xData.forEach((Item, index) => {
				newXData.push(new Date(Item).getTime() / 100000000000);
			});

			// 获取俩个点的数据
			let x0 = kVaule * newXData[0] + bVaule;
			// let xLast = kVaule * newXData.pop() + bVaule;
			let xLast = kVaule * newXData.pop() + bVaule;
			yData.push([xData[0], Math.floor(x0 * 100) / 100]);
			yData.push([
				xData[xData.length - 1],
				Math.floor(xLast * 100) / 100,
			]);

			// 获取所有y轴的点
			// newXData.forEach((Item) => {
			//   let num = kVaule * Item + bVaule;
			//   yData.push(Math.floor(num * 100) / 100);
			// });

			// let lineData = [];
			// for (let i = 0; i < xData.length; i++) {
			//   let arr = [];
			//   arr.push(xData[i], yData[i])
			//   lineData.push({ value: arr });
			// }
			// console.log(yData,"---------------------");
			return yData;
		},


		getTime() {
			let date = new Date();
			let year = date.getFullYear();
			let mounth = date.getMonth() + 1;
			this.formExDate = `${year}-${mounth}`;
		}
	},
	created() {

	},
	mounted() {
		this.getTime();

		this.initFn();
	},
	beforeDestroy() { },
	destroyed() { },
};
</script>

<style lang="scss" scoped>
.export-dialog-view {
	position: fixed;
	width: 100%;
	height: 100%;
	left: 0;
	top: 0;
	z-index: 6;
}

.export-dialog {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 820px;
	height: 657px;
	// height: 292px;
	background: #ffffff;
	box-shadow: 0px 12px 48px 16px rgba(0, 0, 0, 0.05),
		0px 9px 28px 0px rgba(0, 0, 0, 0.08),
		0px 6px 16px -8px rgba(0, 0, 0, 0.15);
	display: flex;
	flex-direction: row;
	padding: 0 12px;
}

.left-lay {
	position: relative;
	width: 30%;
	height: 100%;
	// border-right: 1px solid #ccc;
	display: flex;
	flex-direction: column;
	// background-color: blanchedalmond;

	.left-line {
		width: 100%;
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 0px 20px;
		padding-top: 10px;

		.line-title {
			font-size: 14px;
			font-weight: 700;
			color: rgba(0, 0, 0, 0.85);
			line-height: 22px;
		}

		.line-value {
			font-size: 14px;
			font-weight: 400;
			color: #7b7b7b;
			line-height: 22px;
			margin-left: 10px;
		}
	}

	.left-draw {
		position: absolute;
		top: 100vh;
		width: 750px;
		height: 611px;
		// flex-grow: 1;
		// flex-shrink: 1;
		background-color: bisque;
	}
}

.tip-lay {
	background: red;
	width: 7px;
	border-radius: 4px;
	background: #ccc;
	margin-top: 46px;
	margin: 46px 15px 85px 15px;
}

.right-lay {
	position: relative;
	width: 63%;
	height: 100%;
	display: flex;
	flex-direction: column;

	.el-icon-close {
		font-size: 16px;
		cursor: pointer;
		width: 46px;
		height: 45px;
		line-height: 45px;
	}

	.right-block-container {
		width: 100%;
		display: flex;
		flex-direction: column;
	}

	.text-right {
		padding: 0 !important;
		text-align: right;
	}

	.right-line {
		width: 100%;
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 0px 12px;
		padding-top: 10px;

		.line-title {
			font-size: 14px;
			font-weight: 700;
			color: rgba(0, 0, 0, 0.85);
			line-height: 22px;
			text-align: left;
			margin-right: 10px;
		}

		.line-content {
			flex-grow: 1;
			flex-shrink: 1;
			display: flex;
			flex-direction: row;
			align-items: center;
		}

		.ipt {
			//     width: 368px;
			width: 100%;
			height: 32px;

			::v-deep .el-input__inner {
				width: 100%;
				height: 32px;
			}

			::v-deep .el-input__inner:focus {
				border: 1px solid #dcdfe6;
			}

			::v-deep .el-input__icon {
				line-height: 32px;
				color: #909399;
			}

			::v-deep .el-input__suffix {
				width: 32px;
				right: 0;
				background: #dee0e3;
			}
		}

		.picker {
			width: 130px;
			margin: 0px 10px;

			::v-deep .el-input__inner {
				width: 130px;
			}

			::v-deep .el-input__suffix {
				background: transparent;
			}
		}

		.orange {
			::v-deep .el-input__inner {
				// width: 130px;
				background-color: #FFDEACFF;
			}
		}

		.divider {
			width: 100%;
			height: 1px;
			background-color: #f0f0f0;
		}
	}

	.right-line.bottom-border {
		padding-bottom: 10px;
		// border-bottom: 1px solid #f0f0f0;
	}

	.flex-row {
		flex-direction: row;
	}

	.flex-column {
		flex-direction: column;
	}
}

.split-title {
	width: 100%;
	font-size: 16px;
	font-weight: 700;
	color: rgba(0, 0, 0, 0.85);
	line-height: 22px;
	padding: 12px 12px;
	border-bottom: 1px solid #f0f0f0;
}

.footer-view {
	width: calc(100% - 30px);
	box-sizing: border-box;
	position: absolute;
	z-index: 10;
	bottom: 16px;
	// padding: 0 15px;
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: space-between;
	// background-color: red;
	padding-top: 17px;
	border-top: 1px solid #f0f0f0;
	font-size: 16px;
	font-weight: 700;

	button {
		width: 82px !important;
		height: 32px;
		// background: #ffffff;
		// border: 1px solid #d9d9d9;
		margin-left: 12px;
		border-radius: 4px;
		font-size: 14px;
		font-weight: 500;
		line-height: 0;
	}

	button:nth-child(2) {
		// background: #106ebe;
		// color: #fff;
	}
}

.p0 {
	padding: 12px 0;
}

.LineEcharts_warp {
	width: 1500px;
	height: 500px;
	position: absolute;
	top: -100px;
	left: -7000px;
	background-color: #fff;
	border: 1px solid #c3c3c3;
	border-top: 3px solid #c3c3c3;
}

#LineEcharts {
	width: 1500px;
	height: 500px;
	// position: absolute;
	// top: -100px;
	// left: -700px;
	// background-color: #fff;
	// border: 1px solid #c3c3c3;
	// border-top: 3px solid #c3c3c3;
}
</style>
